const arrayProto = Array.prototype;
const arrayMethods =Object.create(arrayProto);
const methods = [
    'shift', 'unshift', 'pop', 'push', 'sort', 'reverse', 'splice',
]
methods.forEach((method)=>{
    arrayMethods[method] = function(...args){
        arrayProto[method].call(this,...args)
        let inserted = null;
        console.log(args,inserted, '_________-');
        switch (method) {
            case 'splice': // 修改 删除  添加  arr.splice(0,0,100,200,300)
                inserted = args.slice(2); // splice方法从第三个参数起 是增添的新数据
                break;
            case 'push':
            case 'unshift':
                inserted = args;// 调用push 和 unshift 传递的参数就是新增的逻辑
                break;
        }
       
    }
})
let arr = [1,2,3,4];
arr.__proto___ = arrayMethods;
arr.unshift(200)
// console.log(arr);